package net.neptech.controller;

import net.neptech.model.schedule.ScheShift;
import net.neptech.service.ScheShiftService;
import net.neptech.vm.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author HuangZhengmin
 * @desc
 * @Date 2025/8/13 15:29
 * @Version 1.0
 */
@RestController
@RequestMapping("schedule/shift")
public class ScheShiftController {
  @Autowired
  private ScheShiftService scheShiftService;

  /**
   * 根据班次名模糊分页查询
   * @param shiftName
   * @param page
   * @param size
   * @return
   */
  @GetMapping
  public ResponseResult getShift(@RequestParam(value = "shiftName", required = false) String shiftName,
                                 @RequestParam(value = "deptId") Long deptId,
                                 @RequestParam(value = "status") Integer status,
                                 @RequestParam(value = "page", defaultValue = "0") int page,
                                 @RequestParam(value = "size", defaultValue = "10") int size){
    return ResponseResult.success(scheShiftService.getShiftByName(shiftName, deptId,status,page, size));
  }

  /**
   * 添加班次信息
   * @param scheShift
   * @return
   */
  @PostMapping
  public ResponseResult addShift(@RequestBody ScheShift scheShift){
    scheShiftService.addScheShift(scheShift);
    return ResponseResult.success();
  }

  /**
   * 根据id修改班次信息
   * @param scheShift
   * @return
   */
  @PutMapping
  public ResponseResult updateShift(@RequestBody ScheShift scheShift){
    scheShiftService.updateScheShift(scheShift);
    return ResponseResult.success();
  }

  /**
   * 根据id逻辑删除
   * @param id
   * @return
   */
  @DeleteMapping("{id}")
  public ResponseResult deleteShift(@PathVariable("id") Long id){
    scheShiftService.deleteScheShift(id);
    return ResponseResult.success();
  }

  /**
   * 根据科室id查询班次信息
   */
  @GetMapping("{deptId}/{status}")
  public ResponseResult getShiftByDeptId(@PathVariable("deptId") Long deptId,
                                         @PathVariable("status") Integer status){
    return ResponseResult.success(scheShiftService.getShiftByDeptId(deptId, status));
  }
}
